Skip to content

⚡ Bolt: Optimize cold start enrichment hot path#12

Open
lonewolf0708 wants to merge 1 commit intolonewolf0708-patch-10-floodingfrom
bolt-optimize-cold-start-hotpath-16104853658478507756
Open

⚡ Bolt: Optimize cold start enrichment hot path#12
lonewolf0708 wants to merge 1 commit intolonewolf0708-patch-10-floodingfrom
bolt-optimize-cold-start-hotpath-16104853658478507756

Conversation

@lonewolf0708
Copy link
Copy Markdown
Owner

💡 What: The optimization moves the enrichmentMap table and the getColdEnrichment function from the local scope of the updateTorque function to the module level.

🎯 Why: updateTorque is a high-frequency physics update loop that runs at 2000Hz. In Lua, defining a table literal or a function closure inside another function results in a new allocation on every call. At 2000Hz, this means 2000 table and 2000 function allocations per second per engine, which causes significant pressure on the Garbage Collector and wastes CPU cycles.

📊 Impact: Reduces memory churn by 4000 allocations per second per engine. This leads to fewer GC pauses and lower CPU usage for the physics simulation, particularly in cold environments where this logic is active.

🔬 Measurement: The improvement can be verified by monitoring Lua memory usage and GC activity while the engine is in a cold start state. CPU profiling of the physics thread will also show reduced overhead in the updateTorque function.


PR created automatically by Jules for task 16104853658478507756 started by @lonewolf0708

- Moved `enrichmentMap` and `getColdEnrichment` from `updateTorque` to module scope.
- Reduces table and closure allocations in the 2000Hz hot path.
- Decreases pressure on the Lua Garbage Collector.

Co-authored-by: lonewolf0708 <51030924+lonewolf0708@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Repository owner deleted a comment from coderabbitai bot Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant